//
//  CZBaseDetailController.swift
//  GZWeibo007
//
//  Created by demon on 15/12/24.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

class CZBaseDetailController: UIViewController,CZDetailFootViewDelegate{

    /// 数据模型
    var DetailStatus:CZStatus?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = UIColor.whiteColor()
        title = "微博详情"
//        tabBarController?.tabBar.hidden = true
        
        prepareTableUI()
//        if DetailStatus?.retweeted_status == nil{
//            let headView = CZStatusNormalCell()
//            detailTableView.tableHeaderView = headView
//            headView.status = DetailStatus
//        }else{
//            let headView = CZStatusForwardCell()
//            detailTableView.tableHeaderView = headView
//            headView.status = DetailStatus
//        }
    }

    private func prepareTableUI(){
        
//        let detailFootView = CZDetailFootView()
        
        detailFootView.btnDelegate = self
//        detailTableView.delegate = self
//        detailTableView.dataSource = self
        
        self.view.addSubview(detailFootView)
        self.view.addSubview(detailTableView)
    }
    
    //MARK: -UITableViewDelegate,UITableViewDataSource 代理方法
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cell = UITableViewCell()
//        if indexPath.section == 0{
//            
//            if cell.status?.retweeted_status == nil{//说明是原创cell
//                
//                cell.status = DetailStatus
//                cell = CZStatusNormalCell()
//                
//            }else{
//                
//                cell.status = DetailStatus?.retweeted_status
//                cell = CZStatusForwardCell()
//            }

//        }
        
        return cell
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 2
    }
    
//    func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
//        if section == 0{
//            return 0
//        }
//        return 44
//    }
    
    //MARK:- CZDetailFootViewDelegate 代理方法
    /**
     评论微博
    */
    func commentsButtonDidClick() {
        
        let nav = UINavigationController(rootViewController: CZCommentController())
        
        self.presentViewController(nav, animated: true, completion:nil)
    }
    
    /**
    转发微博
    */
    func repostsButtonDidClick() {
        
        let nav = UINavigationController(rootViewController: CZRepostsController())
        
        self.presentViewController(nav, animated: true, completion:nil)
    }
    
    /**
    点赞
    */
    func attitudesButtonDidClick() {
        
        let nav = UINavigationController(rootViewController: CZAttitudesController())
        
        self.presentViewController(nav, animated: true, completion:nil)
    }
    
    //MARK:- 懒加载
    
    /// tableView
    private lazy var detailTableView:UITableView = {
        
        let tableView = UITableView(frame: CGRect(x: 0, y: 74, width: UIScreen.mainScreen().bounds.width, height: UIScreen.mainScreen().bounds.height - 44))
        
        return tableView
    }()
    
    private lazy var detailFootView:CZDetailFootView = CZDetailFootView()
}
